home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!usenet
- From: GHouck <hksys@teleport.com>
- Newsgroups: comp.lang.c
- Subject: Re: Converting numbers to strings?
- Date: Tue, 26 Mar 1996 14:51:11 -0800
- Organization: systems hk
- Message-ID: <315874DF.4357@teleport.com>
- References: <4j4agq$85h@mozo.cc.purdue.edu>
- NNTP-Posting-Host: ip-pdx02-38.teleport.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (WinNT; I)
-
- Brian R. Jones wrote:
- > I am pretty familiar with the functions that convert strings into
- > numbers, but am totally unfamiliar with the reverse process. What
- > I am looking to do is have a program save several files with the
- > same basic file root, but differentiated by a number. For example
- > I have a loop in my code that varies a variable, q, that varies in
- > increments of 100. Each time through the loop, I would like to save
- > a data file called:
- > out1q100.dat
- > out1q200.dat
- > out1q300.dat
- > It seems that if I can simply convert the floating point variable, q,
- > to a string, I could use strcat to add it to the basic filename root,
- > out1q. Is there a simple way to do this? I haven't found anything
- > in the string(s).h file that would do the trick. Many thanks!Brian,
- You might try:
-
- strcpy( filePrefix,"out1q" );
- ...
- sprintf( fileName,"%s%03d.dat",filePrefix,fileNumber );
- fileNumber += 100;
- ...
-
- Yours, Geoff Houck
-